package com.heima.article.controller;

import com.heima.common.aliyun.GreeTextScan;
import com.heima.common.aliyun.GreenImageScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    GreenImageScan greenImageScan;

    @Autowired
    GreeTextScan greeTextScan;

    @PostMapping("/text")
  public Object method(@RequestBody String content) throws Exception {
      Map map = greeTextScan.greeTextScan(content);
      return map;
  }


  @PostMapping("/img")
  public Object img(MultipartFile file) throws Exception {

      ArrayList<byte[]> list=new ArrayList<>();
      list.add(file.getBytes());
       return greenImageScan.imageScan(list);
  }
}
